
    <!DOCTYPE html>
    <html lang="zh-CN">
    <head>
      <meta charset="UTF-8">
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      <title>如何在 Java 的 CMS垃圾收集器中维护卡表，并进行增量更新？ - 学习卡片</title>
      <style>
        body { font-family: sans-serif; background-color: #f0f8ff; color: #333; display: flex; flex-direction: column; align-items: center; padding: 50px 20px; }
        .header h1 { font-size: 32px; }
        .grid-container { display: grid; grid-template-columns: repeat(3, 1fr); gap: 28px; width: 100%; max-width: 1200px; }
        .card-container { perspective: 1200px; cursor: pointer; height: 250px; }
        .card { width: 100%; height: 100%; position: relative; transform-style: preserve-3d; transition: transform 0.7s; border-radius: 16px; box-shadow: 0 4px 16px rgba(0,0,0,0.08); }
        .card-container.flipped .card { transform: rotateY(180deg); }
        .card-face { position: absolute; width: 100%; height: 100%; backface-visibility: hidden; display: flex; flex-direction: column; box-sizing: border-box; border-radius: 16px; background-color: #fff; padding: 24px; }
        .card-back { background-color: #f0fff4; transform: rotateY(180deg); justify-content: space-between; }
        .card-category { font-size: 14px; color: #0052d9; margin-bottom: 8px; font-weight: 500; }
        .card-question { font-size: 20px; font-weight: 500; flex-grow: 1; display: flex; align-items: center; justify-content: center; text-align: center; }
        .card-answer-wrapper { flex-grow: 1; overflow-y: auto; }
        .card-answer { font-size: 15px; line-height: 1.7; }
        .card-footer { font-size: 13px; color: #8a919f; border-top: 1px solid #f0f0f0; padding-top: 16px; margin-top: 16px; }
        .card-source { font-size: 13px; color: #8a919f; border-top: 1px solid #f0f0f0; padding-top: 12px; margin-top: 12px; }
      </style>
    </head>
    <body>
      <div class="header">
        <h1>如何在 Java 的 CMS垃圾收集器中维护卡表，并进行增量更新？ - 学习卡片</h1>
      </div>
      <div class="grid-container">
        
    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">理论</div>
          <div class="card-question">在CMS垃圾收集中，卡表（Card Table）的核心作用是什么？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">理论</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">卡表是一种用于跟踪对象内存区域变化的结构，主要记录哪些内存区域的对象引用可能发生了变化，从而支持增量更新的标记过程并提高垃圾回收效率。</div>
          </div>
          <div class="card-source">来源: 1. 卡表（Card Table）概述</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">机制</div>
          <div class="card-question">CMS收集器是如何确保在对象引用发生变化时，能够及时更新卡表信息的？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">机制</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">CMS收集器使用一种称为“写屏障”（Write Barrier）的机制。当一个对象的引用发生变化时，写屏障会将涉及的内存区域对应的卡标记为“脏”状态，并记录到卡表中。</div>
          </div>
          <div class="card-source">来源: 2. 卡表的维护</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">技术</div>
          <div class="card-question">增量更新（Incremental Update）技术在CMS中的主要目标是什么？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">技术</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">增量更新的主要目的是在并发标记阶段尽量减少对应用程序性能的影响，以此来优化垃圾回收的标记过程。</div>
          </div>
          <div class="card-source">来源: 3. 增量更新（Incremental Update）</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">机制</div>
          <div class="card-question">在CMS的并发标记阶段，增量更新是如何处理新产生的对象引用变化的？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">机制</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">在并发标记阶段，CMS利用写屏障更新卡表来跟踪内存变化。增量更新机制会在并发标记之后，根据这些卡表信息来处理在并发期间发生变化的对象引用，确保所有被修改的引用都被标记。</div>
          </div>
          <div class="card-source">来源: 3. 增量更新（Incremental Update）</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">流程</div>
          <div class="card-question">CMS垃圾收集器在哪个阶段处理被标记为“脏”状态的卡？具体是如何处理的？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">流程</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">CMS在“最终标记”阶段处理脏卡。它会检查所有标记为“脏”状态的卡，并扫描这些卡所涉及的内存区域，从而重新标记在并发标记期间被修改的引用，以保证回收的准确性。</div>
          </div>
          <div class="card-source">来源: 3. 增量更新（Incremental Update）</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">特性</div>
          <div class="card-question">写屏障（Write Barrier）在维护卡表时扮演了什么关键角色？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">特性</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">写屏障是一种在对象引用发生变化时更新卡表的机制。它通过将发生变化的内存区域对应的卡标记为“脏”状态，确保CMS在并发标记期间能够及时捕捉到内存中的引用变化。</div>
          </div>
          <div class="card-source">来源: 2. 卡表的维护</div>
        </div>
      </div>
    </div>

      </div>
    </body>
    </html>
